# 创建的模块用于存储公共使用的函数
def make_pizza(size, *toppings):
    """ 概述要制作的比萨 """
    print("\nMaking a " + str(size) + "-inch pizza with the following toppings:")
    for topping in toppings:
        print("- " + topping)


# 一个用于表示汽车的类
class Car:
    """ 一次模拟汽车的简单尝试 """
    def __init__(self, make, model, year):
        """ 初始化描述汽车的属性 """
        self.make = make
        self.model = model
        self.year = year
        self.odometer_reading = 0

    def get_descriptive_name(self):
        """ 返回整洁的描述性名称 """
        long_name = str(self.year) + ' ' + self.make + ' ' + self.model
        return long_name.title()

    def read_odometer(self):
        """ 打印一条消息，指出汽车的里程 """
        print("This car has " + str(self.odometer_reading) + " miles on it.")

    def update_odometer(self, mileage):
        """
        将里程表读数设置为指定的值
        拒绝将里程表往回拨
        """
        if mileage >= self.odometer_reading:
            self.odometer_reading = mileage
        else:
            print("You can't roll back an odometer!")

    def increment_odometer(self, miles):
        """ 将里程表读数增加指定的量 """
        self.odometer_reading += miles


# 狗类
class Dog:
    """ 一次模拟小狗的简单尝试 """
    # 初始化函数
    # self为Car本身
    # 类似于Java中的有参构造
    def __init__(self, name, age):
        """ 初始化属性 name 和 age"""
        self.name = name
        self.age = age

    def sit(self):
        """ 模拟小狗被命令时蹲下 """
        doSomething = self.name.title() + " is now sitting."
        return doSomething

    def roll_over(self):
        """ 模拟小狗被命令时打滚 """
        doSomething = self.name.title() + " rolled over!"
        return doSomething
